from rest_framework.views import APIView
from rest_framework.permissions import IsAdminUser
from rest_framework.response import Response
from datetime import date
from users.models import User

class UserCountView(APIView):
    #权限认证
    permission_classes = [IsAdminUser]
    def get(self,request):
        #获取当天日期
        now_data = date.today()
        #获取用户总量
        count= User.objects.all().count()
        #返回数据
        return Response({
            'data':now_data,
            'count':count
        })

